<!DOCTYPE html>
<html>

<head>
    <#include "/xhc/admin/components/meta.html" />
    <title>出出帮火车奇妙世界后台 ${metaTitleSuffix!}</title>
    <#include "/xhc/admin/components/stylesheets.html" />
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="4-1" />
            <#include "/xhc/admin/components/menu.html" />
            <el-container>
                <#include "/xhc/admin/components/header.html" />
                <el-main>
                    <template>
                        <div class="search">
                            <!-- <el-date-picker v-model="dateRange" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" unlink-panels="true" :default-value="new Date">
                            </el-date-picker> -->
                            <el-date-picker v-model="date" type="date" value-format="yyyy-MM-dd" :default-value="new Date">
                            </el-date-picker>
                            <el-button @click="onSearch"><i class="el-icon-search"></i>筛选</el-button>
                        </div>
                        <div id="sale-chart" style="width: 1000px; height:500px; margin-bottom: 10px;"></div>
                        <div class="search">
                            <el-date-picker v-model="date2" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" unlink-panels="true" :default-value="new Date">
                            </el-date-picker>
                            <el-button @click="onSearch"><i class="el-icon-search"></i>筛选</el-button>
                        </div>
                        <div>
                            <div class="stat-item">当日销售票数：{{ info.ticketCount }}</div>
                            <div class="stat-item">当日销售单数：{{ info.orderCount }}</div>
                            <div class="stat-item">当日销售额：￥{{ info.totalFee }}</div>
                        </div>
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/xhc/admin/components/footer.html" />
    </div>
    <#include "/xhc/admin/components/scripts.html" />
    <!-- <script src="https://cdn.bootcss.com/echarts/4.1.0-release/echarts.min.js"></script> -->
    <script src="//res.zhen-yee.com/assert/echarts.min.js"></script>
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                info: '',
                date: '',
                date2: '',
                dateRange: ''
            }
        },
        mounted: function() {
            this.info = ${info!'""'}
            this.date = '${date!}'
            var startTime = '${startTime!""}'
            if (startTime != '') {
                this.date2 = new Array;
                this.date2.push('${startTime!}');
                this.date2.push('${endTime!}');
            }
            this.initCharts();
        },
        methods: {
            initCharts() {
                var self = this;
                console.log(self.info)
                var saleChart = echarts.init(document.getElementById('sale-chart'));
                var saleChartOption = {
                    title: {
                        text: '单日时段销售折线图'
                    },
                    tooltip : {
                        trigger: 'axis',
                        formatter: "时间：{b}<br />数量：{c}"
                    },
                    xAxis: {
                        type: 'category',
                        data: self.info.xAxis
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [{
                        data: self.info.yAxis,
                        type: 'line'
                    }]
                };
                saleChart.setOption(saleChartOption);
            },
            onSearch() {
                var self = this;
                var keys = [
                    { key: "date", value: self.date ? self.date : '' }
                ]
                if (self.date2 != null && self.date2.length > 1) {
                    keys.push({ key: 'startTime', value: self.date2[0] });
                    keys.push({ key: 'endTime', value: self.date2[1] });
                } else {
                    keys.push({ key: 'startTime', value: '' });
                    keys.push({ key: 'endTime', value: '' });
                }
                goPage(1, keys);
            }
        }
    })
    </script>
    <style>
    .search {
        margin: 10px 0;
    }

    .stat-item {
        margin-bottom: 10px;
    }
    </style>
</body>

</html>